package com.matthicks.macrobot;

import java.awt.event.KeyEvent;

public enum Key {
	ZERO(KeyEvent.VK_0),
	ONE(KeyEvent.VK_1),
	TWO(KeyEvent.VK_2),
	THREE(KeyEvent.VK_3),
	FOUR(KeyEvent.VK_4),
	FIVE(KeyEvent.VK_5),
	SIX(KeyEvent.VK_6),
	SEVEN(KeyEvent.VK_7),
	EIGHT(KeyEvent.VK_8),
	NINE(KeyEvent.VK_9),
	
	a('a', KeyEvent.VK_A),
	b('b', KeyEvent.VK_B),
	c('c', KeyEvent.VK_C),
	d('d', KeyEvent.VK_D),
	e('e', KeyEvent.VK_E),
	f('f', KeyEvent.VK_F),
	g('g', KeyEvent.VK_G),
	h('h', KeyEvent.VK_H),
	i('i', KeyEvent.VK_I),
	j('j', KeyEvent.VK_J),
	k('k', KeyEvent.VK_K),
	l('l', KeyEvent.VK_L),
	m('m', KeyEvent.VK_M),
	n('n', KeyEvent.VK_N),
	o('o', KeyEvent.VK_O),
	p('p', KeyEvent.VK_P),
	q('q', KeyEvent.VK_Q),
	r('r', KeyEvent.VK_R),
	s('s', KeyEvent.VK_S),
	t('t', KeyEvent.VK_T),
	u('u', KeyEvent.VK_U),
	v('v', KeyEvent.VK_V),
	w('w', KeyEvent.VK_W),
	x('x', KeyEvent.VK_X),
	y('y', KeyEvent.VK_Y),
	z('z', KeyEvent.VK_Z),
	
	A('A', KeyEvent.VK_A, true),
	B('B', KeyEvent.VK_B, true),
	C('C', KeyEvent.VK_C, true),
	D('D', KeyEvent.VK_D, true),
	E('E', KeyEvent.VK_E, true),
	F('F', KeyEvent.VK_F, true),
	G('G', KeyEvent.VK_G, true),
	H('H', KeyEvent.VK_H, true),
	I('I', KeyEvent.VK_I, true),
	J('J', KeyEvent.VK_J, true),
	K('K', KeyEvent.VK_K, true),
	L('L', KeyEvent.VK_L, true),
	M('M', KeyEvent.VK_M, true),
	N('N', KeyEvent.VK_N, true),
	O('O', KeyEvent.VK_O, true),
	P('P', KeyEvent.VK_P, true),
	Q('Q', KeyEvent.VK_Q, true),
	R('R', KeyEvent.VK_R, true),
	S('S', KeyEvent.VK_S, true),
	T('T', KeyEvent.VK_T, true),
	U('U', KeyEvent.VK_U, true),
	V('V', KeyEvent.VK_V, true),
	W('W', KeyEvent.VK_W, true),
	X('X', KeyEvent.VK_X, true),
	Y('Y', KeyEvent.VK_Y, true),
	Z('Z', KeyEvent.VK_Z, true),
	
	F1(KeyEvent.VK_F1),
	F2(KeyEvent.VK_F2),
	F3(KeyEvent.VK_F3),
	F4(KeyEvent.VK_F4),
	F5(KeyEvent.VK_F5),
	F6(KeyEvent.VK_F6),
	F7(KeyEvent.VK_F7),
	F8(KeyEvent.VK_F8),
	F9(KeyEvent.VK_F9),
	F10(KeyEvent.VK_F10),
	F11(KeyEvent.VK_F11),
	F12(KeyEvent.VK_F12),
	F13(KeyEvent.VK_F13),
	F14(KeyEvent.VK_F14),
	F15(KeyEvent.VK_F15),
	F16(KeyEvent.VK_F16),
	F17(KeyEvent.VK_F17),
	F18(KeyEvent.VK_F18),
	F19(KeyEvent.VK_F19),
	F20(KeyEvent.VK_F20),
	F21(KeyEvent.VK_F21),
	F22(KeyEvent.VK_F22),
	F23(KeyEvent.VK_F23),
	F24(KeyEvent.VK_F24),
	
	KEYPAD_DOWN(KeyEvent.VK_KP_DOWN),
	KEYPAD_LEFT(KeyEvent.VK_KP_LEFT),
	KEYPAD_RIGHT(KeyEvent.VK_KP_RIGHT),
	KEYPAD_UP(KeyEvent.VK_KP_UP),
	
	NUMPAD_0('0', KeyEvent.VK_NUMPAD0),
	NUMPAD_1('1', KeyEvent.VK_NUMPAD1),
	NUMPAD_2('2', KeyEvent.VK_NUMPAD2),
	NUMPAD_3('3', KeyEvent.VK_NUMPAD3),
	NUMPAD_4('4', KeyEvent.VK_NUMPAD4),
	NUMPAD_5('5', KeyEvent.VK_NUMPAD5),
	NUMPAD_6('6', KeyEvent.VK_NUMPAD6),
	NUMPAD_7('7', KeyEvent.VK_NUMPAD7),
	NUMPAD_8('8', KeyEvent.VK_NUMPAD8),
	NUMPAD_9('9', KeyEvent.VK_NUMPAD9),
	
	DOWN(KeyEvent.VK_DOWN),
	LEFT(KeyEvent.VK_LEFT),
	RIGHT(KeyEvent.VK_RIGHT),
	UP(KeyEvent.VK_UP),
	
	ACCEPT(KeyEvent.VK_ACCEPT),
	ADD(KeyEvent.VK_ADD),
	AGAIN(KeyEvent.VK_AGAIN),
	ALL_CANDIDATES(KeyEvent.VK_ALL_CANDIDATES),
	ALPHANUMERIC(KeyEvent.VK_ALPHANUMERIC),
	ALT(KeyEvent.VK_ALT),
	ALT_GRAPH(KeyEvent.VK_ALT_GRAPH),
	AMPERSAND('&', KeyEvent.VK_7, true),
	ASTERISK('*', KeyEvent.VK_ASTERISK),
	AT('@', KeyEvent.VK_AT),
	BACK_QUOTE('`', KeyEvent.VK_BACK_QUOTE),
	BACK_SLASH('\\', KeyEvent.VK_BACK_SLASH),
	BACK_SPACE(KeyEvent.VK_BACK_SPACE),
	BEGIN(KeyEvent.VK_BEGIN),
	BRACE_OPEN('{', KeyEvent.VK_BRACELEFT),
	BRACE_CLOSE('}', KeyEvent.VK_BRACERIGHT),
	BRACKET_OPEN('[', KeyEvent.VK_OPEN_BRACKET),
	BRACKET_CLOSE(']', KeyEvent.VK_CLOSE_BRACKET),
	CANCEL(KeyEvent.VK_CANCEL),
	CAPS_LOCK(KeyEvent.VK_CAPS_LOCK),
	CIRCUMFLEX('^', KeyEvent.VK_CIRCUMFLEX),
	CLEAR(KeyEvent.VK_CLEAR),
	CODE_INPUT(KeyEvent.VK_CODE_INPUT),
	COLON(':', KeyEvent.VK_SEMICOLON, true),
	COMMA(',', KeyEvent.VK_COMMA),
	COMPOSE(KeyEvent.VK_COMPOSE),
	CONTEXT_MENU(KeyEvent.VK_CONTEXT_MENU),
	CONTROL(KeyEvent.VK_CONTROL),
	CONVERT(KeyEvent.VK_CONVERT),
	COPY(KeyEvent.VK_COPY),
	CUT(KeyEvent.VK_CUT),
	DECIMAL(KeyEvent.VK_DECIMAL),
	DELETE(KeyEvent.VK_DELETE),
	DIVIDE('/', KeyEvent.VK_DIVIDE),
	DOLLAR('$', KeyEvent.VK_DOLLAR),
	DOUBLE_QUOTE('"', KeyEvent.VK_QUOTEDBL),
	END(KeyEvent.VK_END),
	ENTER(KeyEvent.VK_ENTER),
	EQUALS('=', KeyEvent.VK_EQUALS),
	ESCAPE(KeyEvent.VK_ESCAPE),
	EURO_SIGN(KeyEvent.VK_EURO_SIGN),
	EXCLAMATION_MARK('!', KeyEvent.VK_1, true),
	FINAL(KeyEvent.VK_FINAL),
	FIND(KeyEvent.VK_FIND),
	FORWARD_SLASH('/', KeyEvent.VK_SLASH),
	FULL_WIDTH(KeyEvent.VK_FULL_WIDTH),
	GREATER('>', KeyEvent.VK_GREATER),
	HALF_WIDTH(KeyEvent.VK_HALF_WIDTH),
	HELP(KeyEvent.VK_HELP),
	HIRAGNA(KeyEvent.VK_HIRAGANA),
	HOME(KeyEvent.VK_HOME),
	INPUT_METHOD_ON_OFF(KeyEvent.VK_INPUT_METHOD_ON_OFF),
	INSERT(KeyEvent.VK_INSERT),
	INVERTED_EXCLAMATION_MARK(KeyEvent.VK_INVERTED_EXCLAMATION_MARK),
	JAPANESE_HIRAGANA(KeyEvent.VK_JAPANESE_HIRAGANA),
	JAPANESE_KATAKANA(KeyEvent.VK_JAPANESE_KATAKANA),
	JAPANESE_ROMAN(KeyEvent.VK_JAPANESE_ROMAN),
	KANA(KeyEvent.VK_KANA),
	KANA_LOCK(KeyEvent.VK_KANA_LOCK),
	KANJI(KeyEvent.VK_KANJI),
	KATAKANA(KeyEvent.VK_KATAKANA),
	LESS('<', KeyEvent.VK_LESS),
	META(KeyEvent.VK_META),
	MINUS(KeyEvent.VK_MINUS),
	MODECHANGE(KeyEvent.VK_MODECHANGE),
	MULTIPLY('*', KeyEvent.VK_MULTIPLY),
	NONCONVERT(KeyEvent.VK_NONCONVERT),
	NUM_LOCK(KeyEvent.VK_NUM_LOCK),
	NUMBER_SIGN('#', KeyEvent.VK_NUMBER_SIGN),
	PAGE_DOWN(KeyEvent.VK_PAGE_DOWN),
	PAGE_UP(KeyEvent.VK_PAGE_UP),
	PARENTHESIS_OPEN('(', KeyEvent.VK_9, true),
	PARENTHESIS_CLOSE(')', KeyEvent.VK_0, true),
	PASTE(KeyEvent.VK_PASTE),
	PAUSE(KeyEvent.VK_PAUSE),
	PERCENT('%', KeyEvent.VK_5),
	PERIOD('.', KeyEvent.VK_PERIOD),
	PLUS('+', KeyEvent.VK_PLUS),
	PREVIOUS_CANDIDATE(KeyEvent.VK_PREVIOUS_CANDIDATE),
	PRINT_SCREEN(KeyEvent.VK_PRINTSCREEN),
	PROPS(KeyEvent.VK_PROPS),
	QUESTION_MARK('?', KeyEvent.VK_SLASH, true),
	QUOTE('\'', KeyEvent.VK_QUOTE),
	ROMAN_CHARACTERS(KeyEvent.VK_ROMAN_CHARACTERS),
	SCROLL_LOCK(KeyEvent.VK_SCROLL_LOCK),
	SEMICOLON(';', KeyEvent.VK_SEMICOLON),
	SEPARATOR(KeyEvent.VK_SEPARATOR),
	SHIFT(KeyEvent.VK_SHIFT),
	SPACE(' ', KeyEvent.VK_SPACE),
	STOP(KeyEvent.VK_STOP),
	SUBTRACT('-', KeyEvent.VK_SUBTRACT),
	TAB('\t', KeyEvent.VK_TAB),
	UNDERSCORE('_', KeyEvent.VK_MINUS, true),
	UNDO(KeyEvent.VK_UNDO),
	WINDOWS(KeyEvent.VK_WINDOWS),
	
	UNDEFINED(-1);
	
	private int ascii;
	private int vk;
	private boolean upper;
	
	Key(int ascii) {
		this.ascii = ascii;
		this.vk = ascii;
	}
	
	Key(int ascii, int vk) {
		this.ascii = ascii;
		this.vk = vk;
	}
	
	Key(int ascii, int vk, boolean upper) {
		this.ascii = ascii;
		this.vk = vk;
		this.upper = upper;
	}
	
	public char getChar() {
		return (char)ascii;
	}
	
	public int getASCII() {
		return ascii;
	}
	
	public int getVK() {
		return vk;
	}
	
	public boolean isUpper() {
		return upper;
	}
	
	public static final Key getByASCII(int ascii) {
		for (Key k : Key.values()) {
			if (k.ascii == ascii) {
				return k;
			}
		}
		return null;
	}
	
	public static final Key getByVK(int vk) {
		for (Key k : Key.values()) {
			if (k.vk == vk) {
				return k;
			}
		}
		return null;
	}
	
	public static final Key getByName(String name) {
		for (Key k : Key.values()) {
			if (k.name().equalsIgnoreCase(name)) {
				return k;
			}
		}
		return null;
	}
}